package com.fy56.platform.goodsTracking.service.impl;

import com.dexcoder.dal.JdbcDao;
import com.fy56.platform.goodsTracking.commons.DateUtil;
import com.fy56.platform.goodsTracking.model.GoodsPublic;
import com.fy56.platform.goodsTracking.model.GoodstrackedRecordPublic;
import com.fy56.platform.goodsTracking.model.GoodstrackedRecordTopPublic;
import com.fy56.platform.goodsTracking.model.GoodstrackedRecordTopPublicF6;
import com.fy56.platform.goodsTracking.service.GoodstrackedRecordPublicServie;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by XTK on 2016-11-28.
 */
@Repository
public class GoodstrackedRecordPublicImpl implements GoodstrackedRecordPublicServie {
    static Logger log = Logger.getLogger(GoodstrackedRecordPublicServie.class);
    @Autowired
    JdbcDao jdbcDao_GoodsTracked;

    @Override
    public List<GoodstrackedRecordPublic> selectByNotUpload_Police(String organizationcode, String beginTime, String endTime) {

        String sql = "select GoodsTracked_Record_Public.*,CONVERT(varchar(100), GoodsTracked_Record_Public.SysTime, 20) SYSTIME " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber  " +
                ",GoodsTracked_Record_Top_Public.GoodsNumber " +
                ",GoodsTracked_Record_Top_Public.ManualNumber " +
                "from GoodsTracked_Record_Public WITH(NOLOCK)  " +
                "left join GoodsTracked_Record_Top_Public WITH(NOLOCK)  " +
                "on GoodsTracked_Record_Public.ConsignmentBillMasterId=GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                " where GoodsTracked_Record_Public.Systime<='" + endTime + "'" +
                " and  GoodsTracked_Record_Public.Systime>='" + beginTime + "'" +
                " and GoodsTracked_Record_Public.organizationcode='" + organizationcode + "'" +
              /*  " and (GoodsTracked_Record_Public.upload is null or GoodsTracked_Record_Public.upload is null)" +*/
                " order by GoodsTracked_Record_Public.systime";
        //System.out.print(sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodstrackedRecordPublic.class);
    }

    /**
     *
     * @param organizationcode
     * @param beginTime
     * @param endTime
     * @return
     */
    @Override
    public List<GoodstrackedRecordPublic> selectByNotUpload(String organizationcode, String beginTime, String endTime) {

        String sql = "select GoodsTracked_Record_Public.*,CONVERT(varchar(100), GoodsTracked_Record_Public.SysTime, 20) SYSTIME " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber  " +
                ",GoodsTracked_Record_Top_Public.GoodsNumber " +
                ",GoodsTracked_Record_Top_Public.ManualNumber " +
                "from GoodsTracked_Record_Public WITH(NOLOCK)  " +
                "left join GoodsTracked_Record_Top_Public WITH(NOLOCK)   " +
                "on GoodsTracked_Record_Public.ConsignmentBillMasterId=GoodsTracked_Record_Top_Public.ConsignmentBillMasterId " +
                " where  GoodsTracked_Record_Top_Public.ConsignmentBillMasterId is not null " +
                " and GoodsTracked_Record_Public.Systime>='" + beginTime + "'" +
                " and GoodsTracked_Record_Public.Systime<='" + endTime + "'" +
                " and GoodsTracked_Record_Public.organizationcode='" + organizationcode + "'" +
                " and GoodsTracked_Record_Public.upload is null" +
                " order by GoodsTracked_Record_Public.systime";
        // System.out.print(sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodstrackedRecordPublic.class);
    }

    @Override
    public void updateByupload(GoodstrackedRecordPublic sub) {
        jdbcDao_GoodsTracked.updateForSql("update GoodsTracked_Record_Public " +
                "set upload='" + sub.getUpload()
                + "',uploadError='"
                + sub.getUploaderror() + "' where Recordid=" + sub.getRecordid());
    }
    @Override
    public void saveOrder_temp(GoodstrackedRecordTopPublicF6 sub) {
        String insertSql=" insert into Order_temp(ConsignmentBillMasterId,TracePlatformId,Headquarterscode,Consignmentcode,Consignmentpassword,systime,organizationcode)"
                +"values('"+sub.getConsignmentbillmasterid()+"','"+sub.getTraceplatformid()+"','"+sub.getHeadquarterscode()
                +"','"+sub.getHeadquarterscode()
                +"','"+sub.getHeadquarterspassword()+"','"
                + DateUtil.Now()+"','"+sub.getOrganizationcode()+"')";
        jdbcDao_GoodsTracked.updateForSql(insertSql);
    }

    @Override
    public void updateTyCallback(String recordid,String consignmentbillmasterid,String code,String message){
        jdbcDao_GoodsTracked.updateForSql("update GoodsTracked_Record_Public " +
                "set tyCallbackCode='" + code
                + "',tyCallbackMessage='"
                + message + "' where recordid='" + recordid +"' and consignmentbillmasterid='"+ consignmentbillmasterid +"'");
    }

    @Override
    public void updateTop(String ConsignmentBillNumber,String tracePlatformId,String OrganizationCode,String id) {
        try {
            String sql ="update GoodsTracked_Record_Top_Public  " +
                    "set tracePlatformId='" + tracePlatformId + "',uploadFlag='1' where  ConsignmentBillMasterId='"+id+"'";
//            log.info(" updateTop sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
//            String sql2="update  GoodsTracked_Record_Public  " +
//                    "set tracePlatformId='" + tracePlatformId + "' where OrganizationCode='"+OrganizationCode+"' and ConsignmentBillMasterId='"+id+"'";
//            log.info(" updateTop sql:"+sql2);
//            jdbcDao_GoodsTracked.updateForSql(sql2 );
        }catch (Exception e){
            log.error(" updateTop error:",e);
        }

    }
    @Override
    public void updateTopNew(String ConsignmentBillNumber,String tracePlatformId,String OrganizationCode,String id) {
        try {
            String sql ="update GoodsTracked_Record_Top_Public  " +
                    "set  uploadFlag='1' where  ConsignmentBillMasterId='"+id+"'";
//            log.info(" updateTop sql:"+sql);
            if(tracePlatformId!=null&&tracePlatformId.length()!=0){
                sql ="update GoodsTracked_Record_Top_Public  " +
                        "set  uploadFlag='1',tracePlatformId='"+tracePlatformId+"' where ConsignmentBillMasterId='"+id+"'";
            }
            jdbcDao_GoodsTracked.updateForSql(sql);
//            String sql2="update  GoodsTracked_Record_Public  " +
//                    "set tracePlatformId='" + tracePlatformId + "' where OrganizationCode='"+OrganizationCode+"' and ConsignmentBillMasterId='"+id+"'";
//            log.info(" updateTop sql:"+sql2);
//            jdbcDao_GoodsTracked.updateForSql(sql2 );
        }catch (Exception e){
            log.error(" updateTop error:",e);
        }

    }
    @Override
    public void updateTopErrorCount(int uploadCount,String id) {
        try {
            String sql ="update GoodsTracked_Record_Top_Public  " +
                    "set  uploadCount=Isnull(uploadCount,0)+1 where  ConsignmentBillMasterId='"+id+"'";
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){
            log.error(" updateTopErrorCount error:",e);
        }

    }

    @Override
    public void updatePublic(String ConsignmentBillNumber,String tracePlatformId,String OrganizationCode,String id) {
        try {
            String sql ="update  GoodsTracked_Record_Public  " +
                    "set UNIQUE_NO='" + tracePlatformId + "'"+ " where " +
                    "  RecordID='"+id+"'" ;
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updatePublic error:",e);
        }

    }
    @Override
    public Integer insert(String sql) {
        Integer re=0;
        try {
            re= jdbcDao_GoodsTracked.updateForSql(sql);
            System.out.println("状态:"+re);
        }catch (Exception e){

            log.error("insert error:",e);
        }
        return re;

    }
    @Override
    public List<GoodstrackedRecordTopPublic> selNotUploadList(String organizationcode, String beginTime, String endTime) {

        String sql = "select CONVERT(varchar(100), GoodsTracked_Record_Top_Public.SysTime, 20) SYSTIME " +
                ",GoodsTracked_Record_Top_Public.ConsignmentBillNumber " +
                ",GoodsTracked_Record_Top_Public.GoodsNumber " +
                ",GoodsTracked_Record_Top_Public.ManualNumber,GoodsTracked_Record_Top_Public.* " +
                "from GoodsTracked_Record_Top_Public  " +
                " where  1=1 " +
                " and GoodsTracked_Record_Top_Public.Systime>='" + beginTime + "'" +
                " and GoodsTracked_Record_Top_Public.Systime<='" + endTime + "'" +
//                " and GoodsTracked_Record_Top_Public.organizationcode='" + organizationcode + "'" +
                " and (GoodsTracked_Record_Top_Public.TracePlatformId is null or GoodsTracked_Record_Top_Public.TracePlatformId='') " +
                " order by GoodsTracked_Record_Top_Public.systime asc ";
         System.out.print("selNotUploadList:"+sql);
         List<GoodstrackedRecordTopPublic> result = null;
        try{
            result = jdbcDao_GoodsTracked.queryListForSql(sql, GoodstrackedRecordTopPublic.class);
        }catch (Exception e){
            log.error("selNotUploadList:",e);
            System.out.print("selNotUploadList error:"+e);

        }
        return result;
    }
    @Override
    public List<GoodsPublic> selectByNotUpload_List(String organizationcode, String beginTime, String endTime) {

        String sql = "select   GoodsTracked_Record_Public.SYSTIME" +
        ",GoodsTracked_Record_Public.Createcompanyname createcompanyname  " +
                ",Order_temp.ConsignmentBillMasterId ConsignmentBillMasterId"+
                ",Order_temp.TracePlatformId TracePlatformId"+
                ",Order_temp.Headquarterscode Headquarterscode"+
                ",Order_temp.Consignmentcode Consignmentcode"+
                ",Order_temp.Consignmentpassword Consignmentpassword"+
                ",Order_temp.organizationcode organizationcode"+
                ",GoodsTracked_Record_Public.TypeNum  " +
                ",GoodsTracked_Record_Public.TypeName" +
                ",GoodsTracked_Record_Public.Info " +
                ",GoodsTracked_Record_Public.CreateOperator " +
                ",GoodsTracked_Record_Public.UNIQUE_NO " +
                ",GoodsTracked_Record_Public.RecordID " +
                ",GoodsTracked_Record_Public.Longitude " +
                ",GoodsTracked_Record_Public.Latitude " +
                ",GoodsTracked_Record_Public.DriverCode " +
                ",GoodsTracked_Record_Public.DriverName " +
                ",GoodsTracked_Record_Public.CarLicense " +
                "from GoodsTracked_Record_Public  WITH(NOLOCK)  " +
                "left join Order_temp   WITH(NOLOCK) " +
                "on GoodsTracked_Record_Public.ConsignmentBillMasterId=Order_temp.ConsignmentBillMasterId " +
                " where GoodsTracked_Record_Public.createTime<='" + endTime + "'" +
                " and  GoodsTracked_Record_Public.createTime>='" + beginTime + "'" +
                " and  Order_temp.organizationcode not in('fyrjgs','fycsz')"+
                " and (GoodsTracked_Record_Public.UNIQUE_NO is null or GoodsTracked_Record_Public.UNIQUE_NO='')" +
                " and Order_temp.TracePlatformId is not null"+
                " and Order_temp.TracePlatformId !='失败' "+
                " and Order_temp.TracePlatformId !='' ";
        if(organizationcode!=null&&organizationcode.length()!=0){
            sql= sql+  " and GoodsTracked_Record_Public.organizationcode='" + organizationcode + "'" ;
        }
        sql=sql+ " order by GoodsTracked_Record_Public.systime";
        //System.out.print(sql);
        log.info("selectByNotUpload_List sql:"+sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodsPublic.class);
    }

    @Override
    public List<GoodsPublic> selectWxNotUpload_List(String organizationcode, String beginTime, String endTime) {

        String sql = "    select " +
                "        grtp.Headquartersname Headquartersname, " +
                "        grp.deliverydate deliverydate, " +
                "        grp.receiveperson receiveperson, " +
                "        grp.deliverycompany deliverycompany, " +
                "        grp.arrivalqueryphone arrivalqueryphone, " +
                "        grp.transfercompanysendphone transfercompanysendphone, " +
                "        grp.transfercompanyreceive transfercompanyreceive, " +
                "        grtp.databasename databasename, " +
                "        grtp.WxPublicNumber, " +
                "        grp.SYSTIME, " +
                "        grtp.headquarterphone headquarterphone, " +
                "        grp.TypeNum  , " +
                "        grp.TypeName, " +
                "        grp.Info , " +
                "        grp.CreateOperator , " +
                "        grp.UNIQUE_NO , " +
                "        grp.RecordID , " +
                "        grp.Longitude , " +
                "        grp.Latitude , " +
                "        grp.DriverCode , " +
                "        grp.DriverName , " +
                "        grp.CarLicense , " +
                "        grp.OrganizationCode , " +
                "        grtp.ConsignmentBillMasterId , " +
                "        grtp.ConsignmentBillNumber , " +
                "        grtp.GoodsNumber , " +
                "        grtp.ManualNumber , " +
                "        grtp.ConsignmentBillDate , " +
                "        grtp.PlaceOfLoading , " +
                "        grtp.SendCompany , " +
                "        grtp.ReceiveCompany , " +
                "        grtp.UnloadPlace , " +
                "        grtp.ConsignorCompanyCode , " +
                "        grtp.ConsignorCompany , " +
                "        grtp.Consignor , " +
                "        grtp.ConsignorMobileTelephone , " +
                "        grtp.ConsignorTelephone , " +
                "        grtp.ConsignorAddress , " +
                "        grtp.ConsigneeCompanyCode , " +
                "        grtp.ConsigneeCompany , " +
                "        grtp.Consignee , " +
                "        grtp.ConsigneeMobileTelephone , " +
                "        grtp.ConsigneeTelephone , " +
                "        grtp.ConsigneeAddress , " +
                "        grtp.OneCardCode , " +
                "        grtp.BankName , " +
                "        grtp.AccountHolder , " +
                "        grtp.Account , " +
                "        grtp.PaymentMethod , " +
                "        grtp.GoodsPickupMethod , " +
                "        grtp.ConsignmentBillRemark , " +
                "        grtp.GoodsName , " +
                "        grtp.GoodsPack , " +
                "        grtp.ReceiptNumber , " +
                "        grtp.IsReceipt , " +
                "        grtp.ReceiptCount , " +
                "        grtp.ReceiptRemark , " +
                "        grtp.TotalNumberOfPackages , " +
                "        grtp.TotalWeight , " +
                "        grtp.TotalVolume , " +
                "        grtp.TotalTransportCost , " +
                "        grtp.CollectionGoodsValue , " +
                "        grtp.AdvanceGoodsValue , " +
                "        grtp.AdvanceTransportCost , " +
                "        grtp.DataType , " +
                "        grtp.Consignoridcard , " +
                "        grtp.Consigneeidcard , " +
                "        grtp.Headquarterscode headquarterscode, " +
                "        grtp.Headquarterspassword , " +
                "        grtp.Consignmentcode , " +
                "        grtp.Consignmentpassword , " +
                "        grtp.Arrivalcode , " +
                "        grtp.Arrivalpassword , " +
                "        grtp.TracePlatformId , " +
                "        grtp.ConsignmentLongitude , " +
                "        grtp.ConsignmentLatitude , " +
                "        grtp.ArrivalLongitude , " +
                "        grtp.ArrivalLatitude  " +
                "    from " +
                "        GoodsTracked_Record_Public AS grp WITH(NOLOCK) " +
                "    left join " +
                "        GoodsTracked_Record_Top_Public AS grtp WITH(NOLOCK)  " +
                "        on grp.ConsignmentBillMasterId=grtp.ConsignmentBillMasterId " +
                " left join WeChatSet as wc  WITH(NOLOCK) on grp.OrganizationCode=wc.OrganizationCode and grp.TypeNum=wc.TypeNum and grp.TypeName=wc.TypeName"+
                " where grp.Systime<='" + endTime + "'" +
                " and  grp.Systime>='" + beginTime + "'" +
                " and (grp.WxFlag is null or grp.WxFlag ='')" +
                " and( grp.Typenum in('5','1') or grp.typename in('现金','代收货款转账成功','付货','送货','转非专线','直接配送处理') )"+
                " and grtp.OrganizationCode in("+organizationcode+")"+
                " and grtp.Databasename!='' "+
                "  and wc.IsSend='是' "+
                " order by grp.systime asc ";
        log.info("selectWxNotUpload_List sql:"+sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodsPublic.class);
    }

    @Override
    public List<GoodsPublic> selectXcxNotUpload_List(String organizationcode, String beginTime, String endTime) {

        String sql ="    select jr.appId as xcxpublicnumber," +
                "        grtp.Headquartersname Headquartersname, " +
                "        grtp.databasename databasename, " +
                "        grtp.WxPublicNumber, " +
                "        grp.SYSTIME, " +
                "        grtp.headquarterphone headquarterphone, " +
                "        grp.TypeNum  , " +
                "        grp.TypeName, " +
                "        grp.Info , " +
                "        grp.CreateOperator , " +
                "        grp.UNIQUE_NO , " +
                "        grp.RecordID , " +
                "        grp.Longitude , " +
                "        grp.Latitude , " +
                "        grp.DriverCode , " +
                "        grp.DriverName , " +
                "        grp.CarLicense , " +
                "        grtp.OrganizationCode , " +
                "        grtp.ConsignmentBillMasterId , " +
                "        grtp.ConsignmentBillNumber , " +
                "        grtp.GoodsNumber , " +
                "        grtp.ManualNumber , " +
                "        grtp.ConsignmentBillDate , " +
                "        grtp.PlaceOfLoading , " +
                "        grtp.SendCompany , " +
                "        grtp.ReceiveCompany , " +
                "        grtp.UnloadPlace , " +
                "        grtp.ConsignorCompanyCode , " +
                "        grtp.ConsignorCompany , " +
                "        grtp.Consignor , " +
                "        grtp.ConsignorMobileTelephone , " +
                "        grtp.ConsignorTelephone , " +
                "        grtp.ConsignorAddress , " +
                "        grtp.ConsigneeCompanyCode , " +
                "        grtp.ConsigneeCompany , " +
                "        grtp.Consignee , " +
                "        grtp.ConsigneeMobileTelephone , " +
                "        grtp.ConsigneeTelephone , " +
                "        grtp.ConsigneeAddress , " +
                "        grtp.OneCardCode , " +
                "        grtp.BankName , " +
                "        grtp.AccountHolder , " +
                "        grtp.Account , " +
                "        grtp.PaymentMethod , " +
                "        grtp.GoodsPickupMethod , " +
                "        grtp.ConsignmentBillRemark , " +
                "        grtp.GoodsName , " +
                "        grtp.GoodsPack , " +
                "        grtp.ReceiptNumber , " +
                "        grtp.IsReceipt , " +
                "        grtp.ReceiptCount , " +
                "        grtp.ReceiptRemark , " +
                "        grtp.TotalNumberOfPackages , " +
                "        grtp.TotalWeight , " +
                "        grtp.TotalVolume , " +
                "        grtp.TotalTransportCost , " +
                "        grtp.CollectionGoodsValue , " +
                "        grtp.AdvanceGoodsValue , " +
                "        grtp.AdvanceTransportCost , " +
                "        grtp.DataType , " +
                "        grtp.Consignoridcard , " +
                "        grtp.Consigneeidcard , " +
                "        grtp.Headquarterscode , " +
                "        grtp.Headquarterspassword , " +
                "        grtp.Consignmentcode , " +
                "        grtp.Consignmentpassword , " +
                "        grtp.Arrivalcode , " +
                "        grtp.Arrivalpassword , " +
                "        grtp.TracePlatformId , " +
                "        grtp.ConsignmentLongitude , " +
                "        grtp.ConsignmentLatitude , " +
                "        grtp.ArrivalLongitude , " +
                "        grtp.ArrivalLatitude  " +
                "    from " +
                "        GoodsTracked_Record_Public AS grp WITH(NOLOCK) " +
                "    left join " +
                "        GoodsTracked_Record_Top_Public AS grtp WITH(NOLOCK)  " +
                "        on grp.ConsignmentBillMasterId=grtp.ConsignmentBillMasterId " +
                " left join JRPT jr WITH(NOLOCK) on jr.organizationcode=grp.organizationcode "+
                " where grp.Systime<='" + endTime + "'" +
                " and  grp.Systime>='" + beginTime + "'" +
                " and (grp.XcxFlag is null or grp.XcxFlag ='')" +
                " and grtp.OrganizationCode in("+organizationcode+")"+
//                " and grp.TypeName in('货运单','预受理单','付货','直发','银行','现金')"+
                " and grp.TypeName in('货运单')"+
                " order by grp.systime asc ";
        log.info("selectWxNotUpload_List sql:"+sql);
        return jdbcDao_GoodsTracked.queryListForSql(sql, GoodsPublic.class);
    }
    @Override
    public void updatePublicXcx(String ConsignmentBillNumber,String OrganizationCode,String id) {
        try {
            String sql ="update  GoodsTracked_Record_Public  " +
                    "set XcxFlag='1'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and ConsignmentBillMasterId='"+ConsignmentBillNumber+"'"+
                    " and RecordID='"+id+"'" ;
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updatePublicXcx error:",e);
        }

    }
    @Override
    public void updatePublicWx(String ConsignmentBillNumber,String OrganizationCode,String id) {
        try {
            String sql ="update  GoodsTracked_Record_Public  " +
                    "set WxFlag='1'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and ConsignmentBillMasterId='"+ConsignmentBillNumber+"'"+
                    " and RecordID='"+id+"'" ;
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updatePublicWx error:",e);
        }

    }
    @Override
    public void updatePublicWxMessage(String ConsignmentBillNumber,String OrganizationCode,String id,String message) {
        try {
            String sql ="update  GoodsTracked_Record_Public  " +
                    "set WxFlag='1',wxMessage='"+message+"'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and ConsignmentBillMasterId='"+ConsignmentBillNumber+"'"+
                    " and RecordID='"+id+"'" ;
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updatePublicWx error:",e);
        }

    }
    @Override
    public void updateCar(String trackingNo,String OrganizationCode,String id) {
        try {
            String sql ="update  TransportBillMaster_public  " +
                    "set uploadstate='1',trackingNo='" + trackingNo + "'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and TransportBillMasterId='"+id+"'";
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updateCar error:",e);
        }

    }
    @Override
    public void updateCollection(String trackingNo,String OrganizationCode,String id) {
        try {
            String sql ="update  CollectionGoodsValueAccount_Public  " +
                    "set flag='1',trackingNo='" + trackingNo + "'"+ " where " +
                    " OrganizationCode='"+OrganizationCode+"' " +
                    " and CollectionGoodsValueAccountId='"+id+"'";
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updateCollection error:",e);
        }

    }

    @Override
    public void updateCollectionNew(String trackingNo,String OrganizationCode,String id) {
        try {
            String sql ="update  CollectionGoodsValueAccount_Public  " +
                    "set flagnew='1',trackingNonew='" + trackingNo + "'"+ " where " +
                    "  CollectionGoodsValueAccountId='"+id+"'";
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updateCollection error:",e);
        }

    }
    @Override
    public void updateCollectionCount(String id) {
        try {
            String sql ="update  CollectionGoodsValueAccount_Public  " +
                    "set uploadCount=Isnull(uploadCount,0)+1 where " +
                    "  CollectionGoodsValueAccountId='"+id+"'";
//           log.info("updatePublic sql:"+sql);
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){

            log.error("updateCollection error:",e);
        }

    }
    @Override
    public void updateCollectionsetId(String id) {
        try {
            String sql ="delete from CollectionGoodsValueAccount_Public " +
                    " where CollectionGoodsValueAccountId='"+id+"' ";
            sql +=" and dataType='2' ";
            jdbcDao_GoodsTracked.updateForSql(sql);
        }catch (Exception e){
            log.error("updateCollectionsetId error:",e);
        }

    }
}
